package com.tjsinfo.tjsoa.messageImportant.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.Dao.IJDBCDao;
import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.messageImportant.bo.IMessageImportantMainBo;



public class DeleteMessageAction extends Action {
	private IMessageImportantMainBo importantMainBo;
	private IJDBCDao jdbcdao;

	public IMessageImportantMainBo getImportantMainBo() {
		return importantMainBo;
	}

	public void setImportantMainBo(IMessageImportantMainBo importantMainBo) {
		this.importantMainBo = importantMainBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String id = request.getParameter("id");
		//importantMainBo.delete(id);
		
		String sqlku = "";
		String sql = "";
		for (int i = 1; i <= 5; i++) {
			sqlku = ToolKit.getProperties("com/tjsinfo/tjsoa/mail/properties/systemResource.properties", this).getProperty(Integer.valueOf(i).toString());
			
			if (sqlku!=null && !"".equals(sqlku)) {
				sql = "update "+sqlku+".dbo.t_messageImportant_main set state=1 where id='"+id+"'";
				jdbcdao.executeUpdate(sql);
			}
		}
		jdbcdao.closeStmt();
		jdbcdao.closeConn();
		
		request.setAttribute("linkurl", "tjsinfo/tjsoa/messageImportant/loginSendMain.do");
		request.setAttribute("message", "messageimportant.message.delete");
		return mapping.findForward("success");
	}

	public void setJdbcdao(IJDBCDao jdbcdao) {
		this.jdbcdao = jdbcdao;
	}
}
